package com.qdlc.p2p.biz.tpp.model;

import java.io.IOException;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.qdlc.p2p.common.constant.SinaConstant;
import com.qdlc.p2p.common.util.DateUtil;

/**
 * 新浪支付-查询用户余额
 * 
 * @author ylx
 * @version 2.0
 * @date 2015年8月11日 下午2:47:02
 */
public class SinaQueryBalance extends SinaModel {
	
	/**
	 * 服务名称
	 */
	private String service = "query_balance";
	
	/**
	 * 账户类型：基本户（BASIC） 保证金户（ENSURE） 
	 * 		 准备金（RESERVE） 存钱罐（SAVING_POT）
	 * 默认基本户
	 */
	private String account_type;
	
	/**
	 * 待签名字符数组
	 */
	private String[] signParamNames=new String[]{"version","service","request_time","partner_id","_input_charset","identity_id","identity_type",
			"account_type"};
	
	/**
	 * 提交字符数组
	 */
	private String[] subParamNames=new String[]{"version","service","request_time","partner_id","_input_charset","sign","sign_type","identity_id","identity_type",
			"account_type"};
	
	/******** 响应信息 start ********/
	
	/**
	 * 余额
	 */
	private String balance;
	
	/**
	 * 可用余额
	 */
	private String available_balance;
	
	/**
	 * 存钱罐收益
	 */
	private String bonus;
	
	/******** 响应信息 end ********/
	
	/**
	 * 获取服务名称
	 */
	public String getService() {
		return service;
	}

	public SinaQueryBalance() {
		super();
	}
	
	public SinaQueryBalance(String account_type, String identity_id) {
		super();
		this.account_type = account_type;
		this.setIdentity_type(SinaConstant.IDENTITY_TYPE_UID);
		this.setIdentity_id(identity_id);
		this.setEncode(SinaConstant.ENCODE_TRUE);
		this.setRequest_time(DateUtil.dateStr3(DateUtil.getNow()));
	}

	@Override
	public SinaModel response(String res) throws IOException {
		try {
			JSONObject json = JSON.parseObject(res);
			balance = json.getString("balance");
			available_balance = json.getString("available_balance");
			bonus = json.getString("bonus");
		} catch (Exception e) {
			e.printStackTrace();
		}

		return null;

	}
	
	/**
	 * 设置服务名称
	 */
	public void setService(String service) {
		this.service = service;
	}

	/**
	 * 获取账户类型
	 * 
	 * @return
	 */
	public String getAccount_type() {
		return account_type;
	}

	/**
	 * 设置账户类型
	 * 
	 * @param account_type
	 */
	public void setAccount_type(String account_type) {
		this.account_type = account_type;
	}

	/**
	 * 获取待签名字符数组
	 */
	public String[] getSignParamNames() {
		return signParamNames;
	}

	/**
	 * 设置待签名字符数组
	 */
	public void setSignParamNames(String[] signParamNames) {
		this.signParamNames = signParamNames;
	}

	/**
	 * 获取提交字符数组
	 */
	public String[] getSubParamNames() {
		return subParamNames;
	}

	/**
	 * 设置提交字符数组
	 */
	public void setSubParamNames(String[] subParamNames) {
		this.subParamNames = subParamNames;
	}

	public String getBalance() {
		return balance;
	}

	public void setBalance(String balance) {
		this.balance = balance;
	}

	public String getAvailable_balance() {
		return available_balance;
	}

	public void setAvailable_balance(String available_balance) {
		this.available_balance = available_balance;
	}

	public String getBonus() {
		return bonus;
	}

	public void setBonus(String bonus) {
		this.bonus = bonus;
	}

}
